<template>
  <div id="page-wrapper" class="gray-bg">
    <header-link/>
    <div class="row wrapper border-bottom white-bg page-heading">
      <div class="col-sm-4">
        <h2>用户信息</h2>
        <ol class="breadcrumb">
          <li>
            <router-link :to="{ name: 'home' }">
              <a>主页</a>
            </router-link>
          </li>
          <li class="active">
            <strong>用户信息</strong>
          </li>
        </ol>
      </div>
    </div>

        <div class="wrapper container wrapper-content animated fadeInUp">
          <div class="ibox">
            <div class="ibox-title">
              <h5></h5>
              <div class="ibox-tools">
                <router-link :to="{ name: 'userEdit'}" class="btn btn-primary btn-xs">
                  <i class="fa fa-edit"></i> 编辑
                </router-link>
              </div>
            </div>
              <div class="ibox-content">
                <div class="form-horizontal">
                  <div class="form-group">
                    <label class="col-sm-3 control-label">用户名</label>
                    <div class="col-sm-8">
                      <p class="form-control-static">{{ userDetail.username }}</p>
                    </div>
                  </div>
                  <div class="form-group">
                    <label class="col-sm-3 control-label">邮箱</label>
                    <div class="col-sm-8">
                      <p class="form-control-static">{{ userDetail.email }}</p>
                    </div>
                  </div>
                  <div class="form-group">
                    <label class="col-sm-3 control-label">电话号码</label>
                    <div class="col-sm-8">
                      <p class="form-control-static">{{ userDetail.phone }}</p>
                    </div>
                  </div>
                  <div class="form-group">
                    <label class="col-sm-3 control-label">密码</label>
                    <div class="col-sm-8">
                      <p class="form-control-static"> *********** </p>
                    </div>
                  </div>
                  <div class="form-group">
                    <label class="col-sm-3 control-label">问题</label>
                    <div class="col-sm-8">
                      <p class="form-control-static">{{ userDetail.question }}</p>
                    </div>
                  </div>
                  <div class="form-group">
                    <label class="col-sm-3 control-label">答案</label>
                    <div class="col-sm-8">
                      <p class="form-control-static"> *********** </p>
                    </div>
                  </div>

                  <div class="hr-line-dashed"></div>
                  <div class="form-group">
                    <div class="col-sm-4 col-sm-offset-3">
                      <router-link :to="{ name: 'userEdit'}" class="btn btn-primary">
                        <i class="fa fa-edit"></i> 编辑
                      </router-link>
                    </div>
                  </div>
                </div>
              </div>
          </div>
        </div>

  </div>

</template>

<script>
import header from '@/components/Header.vue'
import server from '@/server/server.js'
export default {
  name: 'userDetail',
  data () {
    return {
      userDetail: {},
      questionList: []
    }
  },
  components: {
    'header-link': header
  },
  created () {
    const vue = this
    // 获取用户信息
    server.get(server.getUserInfoUrl, null, '', false, false, this, function(data) {
      vue.userDetail = data
    })
    // 获取问题列表
    server.get(server.getQuestionListUrl, null, "", true, false, this, function(data) {
      vue.questionList = data
      vue.questionList.forEach(function(element, index) {
          if (element.id == vue.userDetail.question) {
            vue.userDetail.question = element.question
          }
      })
    })
  },
  mounted () {
  },
  methods: {
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
#page-wrapper {
  margin: 0;
}

</style>
